package page.Beans;

import java.sql.Date;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import basicTypes.RAReserve;


public class cancelarResBean {
	private String data;
	private String hora;
	private int rec;
	
	
	public String cancelRes(loginBean x) throws SQLException{
		List<RAReserve> reserva = x.getBd().db_getReserves(x.getUser(), x.getUser());
		boolean isInlist = false;
		RAReserve aux = null;
		
		for(int i = 0; i < reserva.size(); i++){
			aux = reserva.get(i);
			if(aux.getDia().toString().compareTo(data) == 0 && aux.getHora().compareTo(hora) == 0 && aux.getResourceId()==rec){
				isInlist = true;
				break;
			}
		}
		
		if(isInlist){
			x.getBd().db_delReserve(x.getUser(), aux);
			return "suc";
		}
			
		return "fail";
	}


	public String getData() {
		return data;
	}


	public void setData(String data) {
		this.data = data;
	}


	public String getHora() {
		return hora;
	}


	public void setHora(String hora) {
		this.hora = hora;
	}


	public int getRec() {
		return rec;
	}


	public void setRec(int rec) {
		this.rec = rec;
	}
	
	
	
	
	
}